package com.qeegoo.b2bautozityp.moudle.order.view;

//┏┓　　　┏┓ 
//┏┛┻━━━┛┻┓ 
//┃　　　　　　　┃ 　 
//┃　　　━　　　┃ 
//┃　┳┛　┗┳　┃ 
//┃　　　　　　　┃ 
//┃　　　┻　　　┃ 
//┃　　　　　　　┃ 
//┗━┓　　　┏━┛ 
//┃　　　┃  神兽保佑　　　　　　　　 
//┃　　　┃  代码无BUG！ 
//┃　　　┗━━━┓ 
//┃　　　　　　　┣┓ 
//┃　　　　　　　┏┛ 
//┗┓┓┏━┳┓┏┛ 
// ┃┫┫　┃┫┫ 
// ┗┻┛　┗┻┛

import com.qeegoo.b2bautozityp.R;
import com.qeegoo.b2bautozityp.adapter.OrderFragmentAdapter;
import com.qeegoo.b2bautozityp.constant.Constants;
import com.qeegoo.b2bautozityp.databinding.ActivityOrderListBinding;
import com.qeegoo.b2bautozityp.injector.component.DaggerOrderListComponent;
import com.qeegoo.b2bautozityp.moudle.base.AppBar;
import com.qeegoo.b2bautozityp.moudle.base.BaseActivity;
import com.qeegoo.b2bautozityp.moudle.base.LazyLoadFragment;
import com.qeegoo.b2bautozityp.widget.TabBarUtils;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import base.lib.util.NavigateUtils;
import rx.functions.Action0;

/**
 * Created by lk on 2017/9/14.
 */

public class OrderListActivity extends BaseActivity<ActivityOrderListBinding> {

    @Inject
    AppBar mAppbar;

    private String[] titles ={"全部","待发货","已完成"};

    private List<LazyLoadFragment> fragments = new ArrayList<>();

    private Action0 clickRightAction = new Action0() {
        @Override
        public void call() {
            //TODO 前往售后退货页面
            NavigateUtils.startActivity(OrderReturnListActivity.class);
        }
    };
    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_order_list;
    }

    @Override
    protected void initInjector() {
        DaggerOrderListComponent.builder().appComponent(getAppComponent()).activityComponent(getActivityComponent()).build().inject(this);
    }

    @Override
    protected void initViews() {
        initTitle();
        initFragment();
        mBinding.tabLayout.addTab(mBinding.tabLayout.newTab().setText(titles[0]), true);
        mBinding.tabLayout.addTab(mBinding.tabLayout.newTab().setText(titles[1]));
        mBinding.tabLayout.addTab(mBinding.tabLayout.newTab().setText(titles[2]));
        OrderFragmentAdapter mFragmentAdapteradapter =
                new OrderFragmentAdapter(getSupportFragmentManager(), fragments, titles);
        mBinding.viewpager.setAdapter(mFragmentAdapteradapter);
        mBinding.tabLayout.setupWithViewPager(mBinding.viewpager);
        TabBarUtils.setIndicator(mBinding.tabLayout,30,30);
    }

    private void initFragment() {
        fragments.add(OrderFragment.newInstance(Constants.OrderType_0));
        fragments.add(OrderFragment.newInstance(Constants.OrderType_1));
        fragments.add(OrderFragment.newInstance(Constants.OrderType_2));
    }

    private void initTitle() {
        mAppbar.setRight("售后退货",clickRightAction);
        mAppbar.setBgColor(R.color.app_bg);
        mAppbar.setRightTitleColor(R.color.text_sub);
        mAppbar.showLeft();
        initToolBar(mBinding.layoutInclude, mAppbar);
    }



}
